#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <signal.h>

#include <cedule/log.h>

#include "config.h"
#include "server.h"

void fin (int i);
void appli(int no_client_socket);

int main ( int argc, char ** argv )
{
	Config_t * config;
	Server_t * server;
	config = config_create();
	// config_parse_cmdline( config, argc, argv );
	
	if ( ! config_is_valid( config ) ) {
		exit( EXIT_FAILURE );
	}

	start_log( "cedule" );
	log_info( "server started\n" );

	// initialize server with configuration
	server = server_create( config );

	// trap interuptions & stop server
	//signal(SIGINT,fin);                                                                        
	server_run( server );

	// handle interrupts => call server_stop( .. )

	exit( EXIT_SUCCESS );
}


/*
void fin(int i)                               
{                                   
	shutdown(ma_socket,2);                                                  
	close(ma_socket);                                         
	exit(0);
}
*/
